package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.domain.dto.RejectedProductDTO;
import com.dragon.repository.entity.Rejected;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class RejectedVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "退货名称")
    private String name;

    @ApiModelProperty(value = "生产id")
    private Integer produceId;

    @ApiModelProperty(value = "发货状态：0 未发货，1已发货，2，发货完成")
    private Integer deliverStatus;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "退货编号")
    private String rejectedCode;

    @ApiModelProperty(value = "审核状态：0待审核1审核通过2审核不通过3作废4删除")
    private Integer status;

    @ApiModelProperty(value = "退货完成状态：0未完成1完成")
    private Integer rejectedState;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "删除标识 0否 1是")
    private Integer deleted;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "退货产品")
    @NotNull(message = "退货产品不能为空")
    private List<RejectedProductVO> rejectedProductVO;

    @ApiModelProperty(value = "审批流程")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "是否免审 0否 1是")
    private Integer exempt;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Rejected convert(RejectedVO vo) {
        Rejected entity = new Rejected();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Rejected> convertList(List<RejectedVO> list) {
        List<Rejected> resultList = new ArrayList<>();
        for (RejectedVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
